//
//  SWAlbumHeaderView.swift
//  MiU
//
//  Created by linhan on 16/3/28.
//  Copyright © 2016年 MiU. All rights reserved.
//

import Foundation
import UIKit
class SWAlbumHeaderView: UIView
{
    private var _label = UILabel()
    private var _arrow:UIImageView = UIImageView()
    //private var _arrow:UIImageView = UIImageView(image: R.image.editor_camera_icon_down)
    
    init()
    {
        super.init(frame:CGRectZero)
        setup()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var name:String?{
        didSet{
            _label.text = name
            _label.sizeToFit()
            _arrow.x = _label.right + 5
            width = _arrow.right
            //frame = CGRectMake(frame.origin.x, frame.origin.y, _arrow.right, _label.height)
        }
    }
    
    func open()
    {
        UIView.animate(withDuration: 0.2, animations: {
            self._arrow.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI))
        })
    }
    
    func close()
    {
        UIView.animate(withDuration:0.2, animations: {
            self._arrow.transform = CGAffineTransform.identity
        })
    }
    
    private func setup()
    {
        _label.font = SWAppearanceManager.themeStyle.fontOfSize(17)
        _label.textColor = SWAppearanceManager.themeStyle.majorTitleColor
        addSubview(_label)
        
        _arrow.y = 6
        addSubview(_arrow)
        
        frame = CGRectMake(0, 0, 0, 21)
    }
    
    
    
}
